<?php

/*Description of Mapi_Ip_Address
 *
 * @author      Krisna Pranata krisna.pranata@gmail.com <http://vthink.web.id>
 * @author      Lalu Erfandi Maula Yusnu nunenuh@gmail.com <http://vthink.web.id>
 * @copyright   Copyright (c) 2011, Virtual Think Team.
 * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
 * @category	Libraries
 */
class MIpproxy {
    private $talker;
    function __construct(Talker $talker) {
        $this->talker = $talker;
    }
    
    /**
     * This method used for get all Ip Proxi
     * @return type array
     */
    public function get_all_proxy(){
        $sentence = new SentenceUtil();
        $sentence->fromCommand("/ip/proxy/getall");
        $this->talker->send($sentence);
        $rs = $this->talker->getResult();
        $i = 0 ;
        if ($i < $rs->size()){
            return $rs->getResultArray();
        }  else {
            return "No Ip Proxi To Set, Please Your Add Ip Proxi";
        }
    }
    
    /**
     *
     * This method used for set Ip proxy
     * @param type $param array
     * @return type array
     */
    public function set_proxy($param){
        $sentence = new SentenceUtil();
       $sentence->addCommand("/ip/proxy/set");
       foreach ($param as $name => $value){
               $sentence->setAttribute($name, $value);
       }       
       $this->talker->send($sentence);
       return "Sucsess";        
    }
}
